package homework.api.day07._cp;

import java.io.*;

public class ObjectDemo {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        String name = "张三";
        int age = 18;
        String gender = "男";
        String[] otherInfo = {"法外狂徒","罗老师"};
        Student zs = new Student(name,age,gender,otherInfo);
        System.out.println(zs);

        FileOutputStream fos = new FileOutputStream("Student.obj");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(zs);
        oos.close();

        FileInputStream fis = new FileInputStream("Student.obj");
        ObjectInputStream ois = new ObjectInputStream(fis);
        Student stu = (Student)ois.readObject();
        System.out.println(stu);
        ois.close();

    }
}
